# -*- coding: UTF-8 -*-

from numpy import *


def auto_norm(data_set):
	min_val = data_set.min(0)
	max_val = data_set.max(0)
	ranges = max_val - min_val
	norm_date_set = zeros(shape(data_set))
	m = data_set.shape[0]
	norm_date_set = data_set - tile(min_val, (m, 1))
	norm_date_set = norm_date_set / tile(ranges, (m, 1))
	return norm_date_set, ranges, min_val


def file2matrix():
	f = open("datingTestSet.txt")
	lines = f.readlines()
	num_lines = len(lines)
	return_mat = zeros((num_lines, 3))
	label_vector = []
	index = 0
	for line in lines:
		line = line.strip()
		line_list = line.split(' ')
		return_mat[index, :] = line_list[0:3]
		label_vector.append(int(line_list[-1]))
		index += 1

	return return_mat, label_vector
